AsyncCommand
Ecng.ComponentModel
Async delegate command capable of taking argument.
継承元: NotifiableObject
実装: IRevalidatableCommand, ICommand, IDisposable
コンストラクター
AsyncCommand
public AsyncCommand(Func<T, CancellationToken, Task> execute, Func<T, bool> canExecute, bool allowMultipleExecution)
asyncCommand = AsyncCommand(execute, canExecute, allowMultipleExecution)
Creates a new async command.
- execute
- The async execution logic.
- canExecute
- The execution status logic.
- allowMultipleExecution
- Allow multiple concurrent executions.
AsyncCommand
public AsyncCommand(Func<T, Task> execute, Func<T, bool> canExecute, bool allowMultipleExecution)
asyncCommand = AsyncCommand(execute, canExecute, allowMultipleExecution)
Creates a new async command without cancellation support.
- execute
- The async execution logic.
- canExecute
- The execution status logic.
- allowMultipleExecution
- Allow multiple concurrent executions.
プロパティ
CancelCommand
public IRevalidatableCommand CancelCommand { get; }
value = asyncCommand.CancelCommand
Gets the command to cancel the current execution.
IsCancellationRequested
public bool IsCancellationRequested { get; }
value = asyncCommand.IsCancellationRequested
Gets whether cancellation has been requested.
IsExecuting
public bool IsExecuting { get; private set; }
value = asyncCommand.IsExecuting
asyncCommand.IsExecuting = value
Gets whether the command is currently executing.
メソッド
Dispose
public void Dispose()
asyncCommand.Dispose()
Disposes the command and cancels any pending operation.
Dispose
protected virtual void Dispose(bool disposing)
asyncCommand.Dispose(disposing)
Disposes the command resources.
- disposing
- True if disposing managed resources.
ExecuteAsync
public Task ExecuteAsync(T parameter)
result = asyncCommand.ExecuteAsync(parameter)
Executes the command asynchronously.
- parameter
- The command parameter.
戻り値: A task representing the async operation.
RaiseCanExecuteChanged
public void RaiseCanExecuteChanged()
asyncCommand.RaiseCanExecuteChanged()
Invoke CanExecuteChanged event.
イベント
CanExecuteChanged
public event EventHandler CanExecuteChanged
asyncCommand.CanExecuteChanged += handler